package moe.bogos.douro.api.common.capabilities;

import moe.bogos.douro.api.common.network.DouroAPINetworkHandler;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;

public class CapMap implements ICapMap
{
    private CompoundNBT tagCompound;

    public CompoundNBT getMap()
    {
    	return tagCompound == null ? new CompoundNBT() : tagCompound;
    }

    public void setMap(CompoundNBT tagCompound)
    {
        this.tagCompound = tagCompound;
    }
    
    public CompoundNBT saveNBTData()
    {
        return (CompoundNBT) CapMapStorage.MAP_CAP_STORAGE.writeNBT(CapMapProvider.MAP_CAP, this, null);
    }

    public void loadNBTData(CompoundNBT tagCompound)
    {
        CapMapStorage.MAP_CAP_STORAGE.readNBT(CapMapProvider.MAP_CAP, this, null, tagCompound);
    }

    public void dataChanged(PlayerEntity player)
    {
        DouroAPINetworkHandler.updateCap(player, saveNBTData());
    }
}
